<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\ResourceCollection;

class FactoryRentNatureCollection extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        return [
            'code'=>200,
            'message'=>'请求成功',
            'data'=>$this->collection->map(function ($item){
                /**
                 * @var $item \App\Models\FactoryRentNature
                 */
                return [
                    'rent_nature_id'=>$item->id,
                    'name'=>$item->name,
                ];
            })
        ];
    }
}
